package com.imy.accessibility.node;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.imy.accessibility.R;
import com.imy.accessibility.bean.CustomNode;
import com.imy.common.base.adapter.BaseSimpleListAdapter;
import com.imy.common.base.adapter.BaseViewHolder;

import java.util.List;

public class ControlUiNodeAdapter extends BaseSimpleListAdapter<CustomNode, ControlUiNodeAdapter.Holder> {


    public ControlUiNodeAdapter(Context context, List<CustomNode> infos) {
        super(context, infos);
    }

    @Override
    protected void bindView(int position, Holder holder, View convertView, CustomNode bean) {
        if (bean==null){
            holder.nodeTv.setText("解析异常");
        }else {
            String viewIdResourceName = bean.mViewIdResourceName;
            if (viewIdResourceName!=null){
                holder.nodeTv.setText(bean.mClassName+" ResId:"+viewIdResourceName);
            }else {
                holder.nodeTv.setText(bean.mClassName);
            }
        }


    }

    @Override
    protected int getLayoutId() {
        return R.layout.list_item_control_ui_node;
    }

    @Override
    public Holder getHolder(View view) {
        return new Holder(view);
    }

    public static class Holder extends BaseViewHolder{
        private TextView nodeTv;
        public Holder(View itemView) {
            super(itemView);
            nodeTv=itemView.findViewById(R.id.list_item_control_ui_node_tv);
        }
    }
}
